/*
 * Created on 2005-1-3
 */
package org.nanhill.commons.model;

/**
 * must set id and total first ,than call getMinId, getMaxId
 * 
 * @author wang lin
 */
public class SpecificRange {

	private int total;

	private int id;

	private int minRange = 4;

	private int maxRange = 4;
	
	

	/**
	 * @return Returns the maxRange.
	 */
	public int getMaxRange() {
		return maxRange;
	}
	/**
	 * @param maxRange The maxRange to set.
	 */
	public void setMaxRange(int maxRange) {
		this.maxRange = maxRange;
	}
	/**
	 * @return Returns the minRange.
	 */
	public int getMinRange() {
		return minRange;
	}
	/**
	 * @param minRange The minRange to set.
	 */
	public void setMinRange(int minRange) {
		this.minRange = minRange;
	}
	/**
	 * @return Returns the id.
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            The id to set.
	 */
	public void setId(int now) {
		this.id = now;
	}

	/**
	 * @return Returns the total.
	 */
	public int getTotal() {
		return total;
	}

	/**
	 * @param total
	 *            The total to set.
	 */
	public void setTotal(int total) {
		this.total = total;
	}

	public int getMinId() {
		int min = id - minRange;
		int range = total - minRange - maxRange;
		min = min < range ? min : range;
		return 1 < min ? min : 1;
	}

	public int getMaxId() {
		int max = id + maxRange;
		int range = 1 + minRange + maxRange;
		max = max > range ? max : range;
		return max > total ? total : max;

	}
}